<%@ page pageEncoding="UTF-8" %>
<center>
<form name="addWorker" id="addWorker" action="AddWorkerServlet" method="post">
<table style="text-align: right;">
	<tr>
		<td>Imie</td>
		<td><input type="text" name="name" id="name" size="20"/></td>
	</tr>
	<tr>
		<td>Nazwisko</td>
		<td><input type="text" name="surname" id="surname" size="20"/></td>
	</tr>
	<tr>
		<td>Pesel</td>
		<td><input type="text" name="pesel" id="pesel" size="20"/></td>
	</tr>
	<tr>
		<td>Login</td>
		<td><input type="text" name="login" id="login" size="20"/></td>
	</tr>
	<tr>
		<td>Hasło</td>
		<td><input type="password" name="password1" id="password1" size="20"/></td>
	</tr>
	<tr>
		<td>Powtórz hasło</td>
		<td><input type="password" name="password2" id="password2" size="20"/></td>
	</tr>
</table>
<input type="button" onclick="myFun('addWorker')" value="Dodaj Pracownika"/>
</form><br>
</center>
<script>
function myFun(form){
	var name=document.forms[form]["name"].value;
	var surname=document.forms[form]["surname"].value;
	var pesel=document.forms[form]["pesel"].value;
	var login=document.forms[form]["login"].value;
	var pass=document.forms[form]["password1"].value;
	var pass1=document.forms[form]["password2"].value;
	if (name=="" || surname=="" || pesel=="" || login=="" || pass=="" || pass1=="") {
		alert("Wszystkie pola muszą być wypełnione");
	} else if (!(/[0-9]+/.test(pesel))) {
		alert("Pesel musi być numerem");
	} else if (pass!=pass1) {
		alert("Hasło nie zgadza się");
	} else {
		var r=confirm("Potwierdzenie akcji: dodaj pracownika");
		if (r==true){
			document.getElementById(form).submit();
		}
	}
	return false;
}
</script>